/**
 * 
 */
package ar.edu.unq.agenda.ui;



import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.bindings.DateAdapter;
import org.uqbar.arena.layout.ColumnLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.Selector;
import org.uqbar.arena.widgets.TextBox;
import org.uqbar.arena.windows.Dialog;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;
import org.uqbar.ui.jface.view.ErrorViewer;

import ar.unq.edu.agenda.domain.City;
import ar.unq.edu.agenda.domain.Contact;
import ar.unq.edu.agenda.home.Agenda;

/**
 * Esta es la ventana principal que contiene el ABM del usuario
 * @author nicolas
 */
public abstract class ContactWindow extends SimpleWindow<Contact>
{

	public ContactWindow(WindowOwner owner, Contact model) {
		super(owner, model);
	}

	private static final long serialVersionUID = 1L;
	private static final String EXECUTETASK="executeTask";


	

	@Override
	protected void createMainTemplate(Panel mainPanel) {
		this.setTitle("ABM de Contactos");		
		super.createMainTemplate(mainPanel);
	}
	
	@Override
	protected void addActions(Panel actionsPanel) {
		// TODO Auto-generated method stub

	}


	@Override
	protected void createFormPanel(Panel mainPanel) {
		Panel panel = new Panel(mainPanel);
		panel.setLayout(new ColumnLayout(2));
		//Defino Label y TextBox para el nombre
		Label labelName = new Label(panel);
		labelName.setText("Nombre");		
		TextBox name = new TextBox(panel);
		name.bindValueToProperty(Contact.NAME);
		
		//Defino Label y TextBox para el apellido
		Label labelLastName = new Label(panel);
		labelLastName.setText("Apelido");		
		TextBox lastName = new TextBox(panel);
		lastName.bindValueToProperty(Contact.LASTNAME);
		
		//Defino Label y TextBox para el Email
		Label labelEmail = new Label(panel);
		labelEmail.setText("Email");			
		TextBox email = new TextBox(panel);
		email.bindValueToProperty(Contact.EMAIL);
		
		//Defino Label y TextBox para el Teléfono
		Label labelPhone = new Label(panel);
		labelPhone.setText("Phone");					
		TextBox phone = new TextBox(panel);
		phone.bindValueToProperty(Contact.PHONE);
		
		//Defino Label y TextBox para las Observaciones
		Label labelComments = new Label(panel);
		labelComments.setText("Observaciones");					
		TextBox comments = new TextBox(panel);
		comments.bindValueToProperty(Contact.COMMENTS);
		
		//Defino Label y TextBox para la Fecha de Nacimiento
		Label labelBirthDate = new Label(panel);
		labelBirthDate.setText("Fecha de Nacimiento");					
		TextBox birthDate = new TextBox(panel);			
		birthDate.bindValueToProperty(Contact.BIRTHDATE).setAdapter(new DateAdapter());
		
		//Defino Label y Selector para la ciudad
		Label labelCity = new Label(panel);
		labelCity.setText("Ciudad");
		Selector selectorCities =  new Selector(panel);
		selectorCities.setContents(Agenda.getHome(City.class).allInstances(),City.NAME).bindValueToProperty(Contact.CITY);

		Button createContact = new Button(panel);
		createContact.setCaption(this.getButtonCaption());
		createContact.onClick(new MessageSend(this, ContactWindow.EXECUTETASK));
		


	}	
	
	public abstract String getButtonCaption();
	

}
